import React, { Component } from 'react'
import store from '../store'

export default class Brother2 extends Component {
  constructor () {
    super()

    this.state = {
      num: store.getState().count,
      name: store.getState().user
    }
  }

  componentDidMount () {
    store.subscribe(() => {
      // console.log('-------', store.getState())
      this.setState({
        num: store.getState().count,
        name: store.getState().user
      })
    })
  }

  render () {
    return (
      <div>
        Brother2
        <br />
        <br />
        <br />
        仓库中的最新值---{this.state.num}---{this.state.name}
      </div>
    )
  }
}
